<template>
	<!-- 封装隐私授权弹窗，使用uview -->
		<u-popup v-model="show" mode="bottom" :border-radius="20" :mask-close-able="false">
			<view class="privacy-pop">
				<view class="title">温馨提示</view>
				<text class="content text">
					欢迎使用校园服务喵小朋小程序，我们将通过
					<text class="text primary" @click.stop="goPrivacyContract()">{{ privacyContractName }}</text>
					，帮助您了解我们为您提供的服务，我们如何处理个人信息以及您享有的权利。\n我们会严格按照相关法律法规，采取各种安全措施来维护您的个人信息。\n\n
					点击同意按钮，表示您已知情并同意协议。
				</text>
				<view class="button-box">
					<button :plain="true" hover-class="none" class="button cancel" @click="rejectprivacyauthorization()">拒绝</button>
					<button :plain="true" hover-class="none" class="button primary" open-type="agreePrivacyAuthorization" @agreeprivacyauthorization="agreeprivacyauthorization"	>同意</button>
				</view>
			</view>
		</u-popup>
</template>

<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: true
			}, // 是否展示隐私协议弹窗
			
			privacyContractName: {
				type: String,
				default: true
			}, // 隐私协议名称
		},
		data() {
			return {
				
			}
		},
		methods: {
			// 打开隐私协议
			goPrivacyContract() {
				wx.openPrivacyContract({
				  success: () => {}, // 打开成功
				  fail: () => {}, // 打开失败
				  complete: () => {}
				})
			},
			
			// 用户点击拒绝
			rejectprivacyauthorization() {
				this.$emit('agreeprivacyauthorization', false)
			},
			
			// 用户同意隐私协议事件回调
			agreeprivacyauthorization() {
				this.$emit('agreeprivacyauthorization', true)
			}
		},
	}
</script>

<style lang="scss" scoped>
	.privacy-pop {
		.title {
			height: 92rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32rpx;
			font-weight: bold;
			color: #333333;
		}
		.text {
			font-size: 28rpx;
			line-height: 36rpx;
			&.content {
				color: #333333;
				padding: 0 32rpx;
				display: block;
			}
			&.primary {
				color: $uni-color-primary;
			}
		}
		.button-box {
			margin-top: 20rpx;
			display: grid;
			grid-template-columns: repeat(2, 1fr);
			grid-template-rows: 84rpx;
			.button {
				width: 100%;
				height: 100%;
				text-align: center;
				line-height: 84rpx;
				font-size: 30rpx;
				color: $uni-text-color-inverse;
				border: none;
				border-radius: unset;
				padding: 0;
				&.cancel {
					background: #d2d2d2;
				}
				&.primary {
					background: $uni-color-primary;
				}
			}
		}
	}
</style>
